﻿using QLXN.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace QLXN
{
    public partial class Connection : hTekForm
    {
        public Connection()
        {
            InitializeComponent();
        }

        SqlInteraction sql = new SqlInteraction();

        private void Connection_Load(object sender, EventArgs e)
        {            
            worker.RunWorkerAsync();
        }

        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                Thread.Sleep(2000);
                bool flag = sql.Connect();
                if (!flag)
                {                    
                    Config cf = new Config();
                    cf.ShowDialog();                    
                }
            }
            catch (Exception ex)
            { }
        }

        private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                Login log = new Login();
                log.FormClosed += new FormClosedEventHandler(Login_FormClosed);
                log.Show();
                this.Hide();
            }
            catch (Exception ex)
            { }
        }

        void Login_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }
    }
}
